package cn.stylefeng.guns.sys.modular.system.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.modular.system.entity.CompanyInfo;
import cn.stylefeng.guns.sys.modular.system.model.params.CompanyInfoParam;
import cn.stylefeng.guns.sys.modular.system.service.CompanyInfoService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 控制器
 *
 * @author jiangge
 * @Date 2020-09-16 14:20:48
 */
@Controller
@RequestMapping("/companyInfo")
public class CompanyInfoController extends BaseController {

    private String PREFIX = "/modular/system/companyInfo";

    @Autowired
    private CompanyInfoService companyInfoService;

    /**
     * 跳转到主页面
     *
     * @author jiangge
     * @Date 2020-09-16
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/companyInfo.html";
    }

    /**
     * 新增页面
     *
     * @author jiangge
     * @Date 2020-09-16
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/companyInfo_add.html";
    }

    /**
     * 编辑页面
     *
     * @author jiangge
     * @Date 2020-09-16
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/companyInfo_edit.html";
    }

    /**
     * 新增接口
     *
     * @author jiangge
     * @Date 2020-09-16
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(CompanyInfoParam companyInfoParam) {
        this.companyInfoService.add(companyInfoParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author jiangge
     * @Date 2020-09-16
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(CompanyInfoParam companyInfoParam) {
        this.companyInfoService.update(companyInfoParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author jiangge
     * @Date 2020-09-16
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(CompanyInfoParam companyInfoParam) {
        this.companyInfoService.delete(companyInfoParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author jiangge
     * @Date 2020-09-16
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(CompanyInfoParam companyInfoParam) {
        CompanyInfo detail = this.companyInfoService.getById(companyInfoParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author jiangge
     * @Date 2020-09-16
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(CompanyInfoParam companyInfoParam) {
        return this.companyInfoService.findPageBySpec(companyInfoParam);
    }

}


